home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio
/
Ham Radio CD-ROM (Emerald Software) (1995).ISO
/
misc
/
miscbas
/
satelite.bas
< prev
Wrap
BASIC Source File
|
1992-01-01
|
6KB
|
180 lines
Date: Mon, 14 Dec 87 10:29:53 est
From: allegra!ulysses!sfmag!sfsup!sfmin!martyf@EDDIE.MIT.EDU
Subject: Satellite Tracking Program Submission
Enclosed is a basic program that calculates the azimuth and elevation
for satellite tracking systems. The source of this program is unknown,
however it appears to do the job.
Marty Fleming
attunix!martyf
201 522 5001
-------------cut here----------------
0 GOTO 10'geosynch
1 CHAIN "ENTRY":RETURN
10 ON KEY(1) GOSUB 1
20 ' ** GEOSYNCH **
30 ' **********************
50 CLEAR :SCREEN 2:CLS:KEY OFF
90 OPTION BASE 1
100 DIM AZIMUTH(360),ELEVATION(360)
110 DIM VLINE(39)
120 '
130 ' Create vertical line for use later
140 LINE (0,0)-(0,150)
150 GET (0,0)-(0,150),VLINE
160 '
170 ' Define radian and degree conversion functions
180 DEGREESPERRADIAN = 57.29578
190 DEF FNRAD(DEGREES) = DEGREES/DEGREESPERRADIAN
200 DEF FNDEG(RADIANS) = RADIANS*DEGREESPERRADIAN
210 '
220 ' Define ARC COS function
230 DEF FNACS(X) = 1.570796-ATN(X/SQR(1-X*X))
240 '
250 ' Get antenna latitude and longitude from user
260 ' Also ask for output guidance (printer or not)
270 CLS
280 LOCATE 3,15
290 PRINT "* * * GEOSYNCHRONOUS SATELLITE ANTENNA AIM * * *"
300 LOCATE 8,1
310 PRINT "Latitude (-90 to 90) is positive in the northern hemisphere ...
320 LOCATE 10,1
330 INPUT "Enter the latitude of the antenna location ";LATITUDE
340 LOCATE 13,1
350 PRINT "Longitude (-180 to 180) is positive in the western hemisphere ..."
360 LOCATE 15,1
370 INPUT "Enter the longitude of the antenna location ";LONGITUDE
380 LOCATE 18,9
390 PRINT "1. Screen chart only.
400 LOCATE 19,9
410 PRINT "2. Printed table also. (Must have printer ready).
420 LOCATE 22,1
430 PRINT "Press the appropriate number key, '1' or '2' ...
440 K$ = INKEY$
450 IF K$ <> "1" AND K$ <> "2" THEN 440
460 IF K$ = "2" THEN TABLEFLAG = 1 ELSE TABLEFLAG = 0
470 '
480 ' Build screen chart
490 CLS
500 LOCATE 1,10
510 PRINT "* * * GEOSYNCHRONOUS SATELLITE ANTENNA AIM * * * (Esc to exit)"
520 LOCATE 6,60
530 PRINT "Antenna Location";
540 LOCATE 8,60
550 PRINT USING "Latitude ###.##";LATITUDE;
560 LOCATE 9,60
570 PRINT USING "longitude ###.##";LONGITUDE;
580 LOCATE 13,60
590 PRINT "Satellite";
600 LOCATE 14,60
610 PRINT "longitude";
620 LOCATE 18,60
630 PRINT "Antenna aim";
640 LOCATE 20,60
650 PRINT "Azimuth";
660 LOCATE 21,60
670 PRINT "Elevation";
680 LINE (100,190)-(461,40),,B
690 LOCATE 25,14
700 PRINT "Satellite equatorial longitude (-180 to +180)";
710 '
720 ' Loop to put 12 words vertically on left
730 FOR I = 1 TO 12
740 LOCATE 5+I,1
750 READ A$
760 PRINT A$;
770 NEXT I
780 DATA Antenna,aiming,curves,"","","",""
790 DATA Azimuth,-90 to +90,""
800 DATA Elevation,0 to 90
810 '
820 ' Some of the math can be done just once to save time
830 EARTH = 6367
840 ORBIT = 42200!
850 EARTH2 = EARTH * EARTH
860 ORBIT2 = ORBIT * ORBIT
870 FACTOR = 2 * ORBIT * EARTH * COS(FNRAD(LATITUDE))
880 SINLAT = SIN(FNRAD(LATITUDE))
890 '
900 ' Compute antenna aim for 360 satellite locations
910 FOR SATLONG = 1 TO 360
920 PUT (SATLONG+101,40),VLINE,XOR
930 LONGDIFF = FNRAD(SATLONG - LONGITUDE - 180)
940 TERM1 = SQR(EARTH2 + ORBIT2 - FACTOR * COS(LONGDIFF))
950 TERM2 = TERM1 * TERM1
960 TERM3 = (TERM2 + EARTH2 - ORBIT2) / (2 * TERM1 * EARTH)
970 TERM4 = TAN(LONGDIFF) / SINLAT
980 AZIMUTH(SATLONG) = FNDEG(ATN(TAN(LONGDIFF)/SINLAT))
990 ELEVATION(SATLONG) = FNDEG(FNACS(TERM3)) - 90
1000 GOSUB 1590
1010 IF ELEVATION(SATLONG) < 0 THEN 1080
1020 '(Else plot the points on the chart)
1030 XP = SATLONG + 100
1040 YA = -15 * AZIMUTH(SATLONG) / 18 + 115
1050 YE = -15 * ELEVATION(SATLONG) / 9 + 190
1060 PSET (XP,YA)
1070 PSET (XP,YE)
1080 PUT (SATLONG+101,40),VLINE,XOR 'Erases line but not background
1090 NEXT SATLONG
1100 '
1110 ' Put line at peak elevation point on chart
1120 LOCATE 2,34
1130 PRINT SPACE$(11);
1140 SATLONG = CVI(MKI$(LONGITUDE + 180))
1150 GOSUB 1590
1160 PUT (SATLONG+100,40),VLINE,XOR
1170 IF TABLEFLAG = 0 THEN 1380
1180 '
1190 ' Output table to printer
1200 LPRINT TAB(15)"* * * GEOSYNCHRONOUS SATELLITE ANTENNA AIM * * *"
1210 LPRINT STRING$(2,10)
1220 LPRINT USING "Antenna latitude ###.##";LATITUDE
1230 LPRINT USING "Antenna longitude ###.##";LONGITUDE
1240 LPRINT STRING$(3,10)
1250 LPRINT TAB(9)"Satellite"TAB(27)"Antenna"TAB(36)"Antenna"
1260 LPRINT TAB(9)"Longitude"TAB(27)"Azimuth"TAB(36)"Elevation"
1270 LPRINT STRING$(80,"-");
1280 FORMAT$ = SPACE$(10) + "######" + SPACE$(11)
1290 FORMAT$ = FORMAT$ + "###.## ###.##"
1300 FOR LLONG = 1 TO 360
1310 IF ELEVATION(LLONG) <= 0 THEN 1330
1320 LPRINT USING FORMAT$;LLONG-180,AZIMUTH(LLONG),ELEVATION(LLONG)
1330 NEXT LLONG
1340 LPRINT CHR$(12);
1350 TABLEFLAG = 0
1360 '
1370 ' Manual scroll through screen chart
1380 LOCATE 4,17
1390 PRINT "Use '+' or '-' to scroll through chart"
1400 '
1410 K$ = INKEY$
1415 IF K$=CHR$(27) THEN CLS:END
1420 IF K$ <> "" THEN 1460 ELSE GOSUB 1590
1430 GOTO 1410
1440 '
1450 ' Move line left one notch
1460 IF K$ <> "-" THEN 1530
1470 PUT (SATLONG+100,40),VLINE,XOR
1480 SATLONG = SATLONG - 1
1490 IF SATLONG < 1 THEN SATLONG = 360
1500 GOTO 1160
1510 '
1520 ' Move line right one notch
1530 IF K$ <> "+" THEN 1410
1540 PUT (SATLONG+100,40),VLINE,XOR
1550 SATLONG = SATLONG MOD 360 + 1
1560 GOTO 1160
1570 '
1580 ' Subroutine to update numbers on screen
1590 LOCATE 14,72
1600 PRINT USING "####";SATLONG - 180
1610 LOCATE 20,70
1620 IF ELEVATION(SATLONG) >= 0 THEN PRINT USING "###.##";AZIMUTH(SATLONG);
1630 IF ELEVATION(SATLONG) < 0 THEN PRINT "------";
1640 LOCATE 21,70
1650 IF ELEVATION(SATLONG) >= 0 THEN PRINT USING "###.##";ELEVATION(SATLONG);
1660 IF ELEVATION(SATLONG) < 0 THEN PRINT "------";
1670 RETURN